<script setup lang="ts">
import { buildStyles, getSize } from "../utils";

interface DividerProps {
  width?: number | string;
  padding?: string;
  lineColor?: string;
}

const props = withDefaults(defineProps<DividerProps>(), {
  padding: "16px 0",
  lineColor: "#f2f2f2",
});

const styles = buildStyles(() => ({
  width: getSize(props.width),
  padding: props.padding,
}));

const slots = defineSlots();
</script>

<template>
  <div class="umi-divider" :style="styles">
    <div class="umi-divider-content" v-if="slots.default">
      <slot></slot>
    </div>
  </div>
</template>

<style lang="scss" scoped>
.umi-divider {
  position: relative;
  display: flex;
  text-align: center;
  align-items: center;
  font-size: 12px;

  &-content {
    padding: 0 10px;
  }

  &::before,
  &::after {
    display: block;
    content: " ";
    height: 1px;
    flex: 1;
    background-color: #f2f2f2;
    border-radius: 10px;
  }
}
</style>
